package com.example.interview.example.bankCallSystem.impl_1;

import java.util.ArrayList;
import java.util.List;
//客户 = 编码
public class NumberManager {
    private int lastNumber = 0;
    private List queueNumbers = new ArrayList();

    public synchronized Integer generateNewNumber(){
        queueNumbers.add(++lastNumber);//程序运行着就一直生成
        return lastNumber;
    }

    public synchronized Integer fetchNumber(){
        if(queueNumbers.size()>0){
            return (Integer)queueNumbers.remove(0);
        }else{
            return null;
        }
    }
}
